package com.gxa.employment.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.conditions.update.UpdateChainWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gxa.employment.common.Result;
import com.gxa.employment.entity.dto.PageBean;
import com.gxa.employment.entity.pojo.Enterprise;
import com.gxa.employment.entity.pojo.Job;
import com.gxa.employment.entity.pojo.JobEnterprise;
import com.gxa.employment.service.EnterpriseService;
import com.gxa.employment.service.JobEenterpriseService;
import com.gxa.employment.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 企业岗位表 前端控制器
 * </p>
 *
 * @author author
 * @since 2025-03-25
 */
@RestController
@RequestMapping("/job")
public class JobController {
    @Autowired
    private JobService jobService;
    @Autowired
    private JobEenterpriseService jobEenterpriseService;

    @PostMapping("/update")
    public Result update(@RequestBody Job job) {
        boolean update = jobService.updateById(job);
        return Result.success(update);

    }

    @PostMapping("/add")
    public Result add(@RequestBody Job job) {
        boolean saveResult = jobService.save(job);
        return Result.success(saveResult);
    }

    @DeleteMapping  ("/delete/{id}")
    public Result delete(@PathVariable Integer id) {
        QueryWrapper<Job> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("job_id", id);
        boolean remove = jobService.remove(queryWrapper);
        return Result.success(remove);
    }

    @GetMapping("/page")
    public Page<JobEnterprise> getPage(PageBean pageBean) {
        return jobEenterpriseService.getjobPage(pageBean);
    }
}


